<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="/css/adminMenu.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" language="javascript" src="/js/jquery-1.6.1.min.js"></script>
	<script type="text/javascript" language="javascript" src="/js/ajaxfileupload.js"></script>
	<script type="text/javascript" language="javascript" src="/js/tool.js"></script>
	<title>琥珀川 - 管理演员列表</title>
	<style type="text/css">
		/*标题Font*/
		.tableTitleFont{
			padding-left:5px;
			color:white;
			font-size:14px;
			white-space:nowrap;
		}
		/*选项Font*/
		.itemFont{
			color:#666;
			font-size:12px;
			white-space:nowrap;
		}
		/*重复Font*/
		.repeatFont{
			color:green;
			font-weight:bold;
			font-size:12px;
			white-space:nowrap;
		}
		/*选项A*/
		.itemA{
			color:#09F;
			text-decoration:none;
			font-size:12px;
			white-space:nowrap;
		}
		input{
			margin:0px;
		}
	</style>
</head>

<body>
	<jsp:include page="/admin/include/menu" flush="true"/>
	<form id="searchForm" action="/admin/actorList" method="get">
		<div class="mainDiv">
			<div>
				<table border="1">
					<tr>
						<td>
							<font>搜索:</font>
						</td>
						<td>
							<select id="searchType" name="searchType" onchange="submitSearchForm()">
								<option value="" <c:if test="${searchType==''}">selected="selected"</c:if>>演员</option>
								<option value="movie" <c:if test="${searchType=='movie'}">selected="selected"</c:if>>电影</option>
								<option value="role" <c:if test="${searchType=='role'}">selected="selected"</c:if>>角色</option>
							</select>
							<input id="searchKey" name="searchKey" type="text" value="${searchKey}"/>
							<A class="itemA" href="javascript:submitSearchForm()">[搜索]</A>
							<A class="itemA" href="javascript:clickClearSearchKey()">[清除]</A>
							<%--变红的关键字--%>
							<c:set var="redSearchKey" value="<font style='color:red;'>${searchKey}</font>"></c:set>
						</td>
						<td>
							<font>操作:</font>
						</td>
						<td>
							<input id="state" name="state" type="hidden" value="${state}"/>
							<c:choose>  
								<c:when test="${state == 'edit'}">
									<A class="itemA" href="javascript:clickSave()">[保存]</A>
									<A class="itemA" href="javascript:clickCancelEdit()">[取消编辑]</A>
								</c:when>
								<c:otherwise>
									<A class="itemA" href="javascript:clickEdit()">[编辑]</A>
								</c:otherwise>
							</c:choose>
							<A class="itemA" href="javascript:clickDeleteSelectActor()">[删除选中]</A>
						</td>
					</tr>
				</table>
			</div>
			<div>
				<table border="1">
					<tr>
						<td>
							<font>显示:</font>
						</td>
						<td>
							<select id="showRow" name="showRow" onchange="submitSearchForm()">
								<option value="" <c:if test="${showRow==''}">selected="selected"</c:if>>全部</option>
								<option value="not" <c:if test="${showRow=='not'}">selected="selected"</c:if>>缺少</option>
								<option value="notLogo" <c:if test="${showRow=='notLogo'}">selected="selected"</c:if>>缺少头像</option>
								<option value="notBaike" <c:if test="${showRow=='notBaike'}">selected="selected"</c:if>>缺少百科</option>
								<option value="notXlwb" <c:if test="${showRow=='notXlwb'}">selected="selected"</c:if>>缺少新浪微博</option>
								<option value="notTxwb" <c:if test="${showRow=='notTxwb'}">selected="selected"</c:if>>缺少腾讯微博</option>
								<option value="notBdtb" <c:if test="${showRow=='notBdtb'}">selected="selected"</c:if>>缺少百度贴吧</option>
							</select>
						</td>
						<td>
							<input id="showLogo" onclick="changeShowState()" type="checkbox" 
								<c:if test="${showCol.showLogo}">checked</c:if> 
							/><font class="itemFont">演员照片</font>
							<input id="showName" onclick="changeShowState()" type="checkbox" 
								<c:if test="${showCol.showName}">checked</c:if> 
							/><font class="itemFont">演员名</font>
						</td>
						<td>
							<div>
								<input type="radio" id="showBaikeInfo" name="showMain" onclick="changeShowState()" 
									<c:if test="${showCol.showBaikeInfo}">checked</c:if> 
								/>
								<input id="showBaike" onclick="changeShowState()" type="checkbox" 
									<%--显示数据信息--%>
									<c:if test="${showCol.showBaike}">checked</c:if>
									<c:if test="${showCol.showBaikeInfo == false}">disabled="disabled"</c:if>
								/><font class="itemFont">百科</font>
								<input id="showXlwb" onclick="changeShowState()" type="checkbox"
									<%--显示数据信息--%>
									<c:if test="${showCol.showXlwb}">checked</c:if>
									<c:if test="${showCol.showBaikeInfo == false}">disabled="disabled"</c:if>
								/><font class="itemFont">新浪微博</font>
								<input id="showTxwb" onclick="changeShowState()" type="checkbox"
									<%--显示数据信息--%>
									<c:if test="${showCol.showTxwb}">checked</c:if>
									<c:if test="${showCol.showBaikeInfo == false}">disabled="disabled"</c:if>
								/><font class="itemFont">腾讯微博</font>
								<input id="showBdtb" onclick="changeShowState()" type="checkbox"
									<%--显示数据信息--%>
									<c:if test="${showCol.showBdtb}">checked</c:if>
									<c:if test="${showCol.showBaikeInfo == false}">disabled="disabled"</c:if>
								/><font class="itemFont">百度贴吧</font>
							</div>
							<div>
								<input type="radio" id="showMovieInfo" name="showMain" onclick="changeShowState()" 
									<c:if test="${showCol.showMovieInfo}">checked</c:if> 
								/>
								<input id="showMovie" onclick="changeShowState()" type="checkbox"
									<%--显示电影信息--%>
									<c:if test="${showCol.showMovie}">checked</c:if>
									<c:if test="${showCol.showMovieInfo == false}">disabled="disabled"</c:if>
								/><font class="itemFont">电影</font>
								<input id="showMovieCount" onclick="changeShowState()" type="checkbox"
									<%--显示电影信息--%>
									<c:if test="${showCol.showMovieCount}">checked</c:if>
									<c:if test="${showCol.showMovieInfo == false}">disabled="disabled"</c:if>
								/><font class="itemFont">电影数量</font>
							</div>
						</td>
						<td>
							<input id="showWeight" onclick="changeShowState()" type="checkbox" 
								<c:if test="${showCol.showWeight}">checked</c:if> 
							/><font class="itemFont">权重</font>
						</td>
						<td>
							<div>
								<input id="showCreateTime" name="showTime" onclick="changeShowState()" type="radio" 
									<c:if test="${showCol.showCreateTime}">checked</c:if> 
								/><font class="itemFont">创建时间</font>
							</div>
							<div>
								<input id="showUpdateTime" name="showTime" onclick="changeShowState()" type="radio" 
									<c:if test="${showCol.showUpdateTime}">checked</c:if> 
								/><font class="itemFont">更新时间</font>
							</div>
						</td>
						<td>
							<font>排序:</font>
						</td>
						<td>
							<select id="order" onchange="changeShowState()">
								<option value="id" <c:if test="${order=='id'}">selected="selected"</c:if>>id</option>
								<option value="name" <c:if test="${order=='name'}">selected="selected"</c:if>>演员名</option>
								<option value="movieCount" <c:if test="${order=='movieCount'}">selected="selected"</c:if>>电影数量</option>
								<option value="weight" <c:if test="${order=='weight'}">selected="selected"</c:if>>权重</option>
								<option value="createTime" <c:if test="${order=='createTime'}">selected="selected"</c:if>>创建时间</option>
								<option value="updateTime" <c:if test="${order=='updateTime'}">selected="selected"</c:if>>更新时间</option>
							</select>
							<input id="asc" onclick="changeShowState()" type="checkbox" <c:if test="${asc}">checked</c:if> />升序
						</td>
					</tr>
				</table>
			</div>
			<div>
				<table style="border:1px solid black;" border="0" width="100%">
					<tr style="background-color:#09F; color:white;">
						<td align="center"><input id="selectAll" type="checkbox" onclick="clickSelectAll()"/></td>
						<td align="center">
							<font class="tableTitleFont">no</font>
						</td>
						<td align="center">id</td>
						<c:if test="${showCol.showLogo}">
							<td align="center">
								<font class="tableTitleFont">演员照片</font>
							</td>
						</c:if>
						<c:if test="${showCol.showName}">
							<td align="center">
								<font class="tableTitleFont">演员名</font>
							</td>
						</c:if>
						<%--显示数据信息--%>
						<c:if test="${showCol.showBaikeInfo}">
							<c:if test="${showCol.showBaike}">
								<td>
									<font class="tableTitleFont">百科</font>
								</td>
							</c:if>
							<c:if test="${showCol.showXlwb}">
								<td>
									<font class="tableTitleFont">新浪微博</font>
								</td>
							</c:if>
							<c:if test="${showCol.showTxwb}">
								<td>
									<font class="tableTitleFont">腾讯微博</font>
								</td>
							</c:if>
							<c:if test="${showCol.showBdtb}">
								<td>
									<font class="tableTitleFont">百度贴吧</font>
								</td>
							</c:if>
						</c:if>
						<%--显示电影信息--%>
						<c:if test="${showCol.showMovieInfo}">
							<c:if test="${showCol.showMovie}">
								<td>
									<font class="tableTitleFont">电影</font>
								</td>
							</c:if>
							<c:if test="${showCol.showMovieCount}">
								<td align="center">
									<font class="tableTitleFont">数量</font>
								</td>
							</c:if>
						</c:if>
						<c:if test="${showCol.showWeight}">
							<td align="center">
								<font class="tableTitleFont">权重</font>
							</td>
						</c:if>
						<c:if test="${showCol.showCreateTime}">
							<td align="center">
								<font class="tableTitleFont">创建</font>
							</td>
						</c:if>
						<c:if test="${showCol.showUpdateTime}">
							<td align="center">
								<font class="tableTitleFont">更新</font>
							</td>
						</c:if>
						<td align="center">
							<font class="tableTitleFont">操作</font>
						</td>
					</tr>
					<c:forEach items="${actorList}" varStatus="status" var="aActor">
						<tr 
							<c:choose>
								<c:when test="${status.index % 2 == 0}">style="background-color:#FCC;"</c:when>
								<c:otherwise>style="background-color:#FFC;"</c:otherwise>
							</c:choose>
						>
							<td align="center">
								<input id="select_${status.index}" type="checkbox" />
							</td>
							<td align="center">
								${status.index+1}
							</td>
							<td align="center"> 
								${aActor.id}
								<input id="id_${status.index}" type="hidden" value="${aActor.id}"/>
							</td> 
							
							<%--显示演员头像--%>
							<c:if test="${showCol.showLogo}">
								<td align="center">
									<div style="width:148px; border:1px solid black; height:170px; overflow:hidden;">
										<img id="logoImg_${status.index}" 
											<c:choose>  
												<c:when test="${aActor.logoPath == ''}">
													src="/image/system/defaultActorLogo.png"
												</c:when>
												<c:otherwise> 
													src="${aActor.logoPath}"
												</c:otherwise>
											</c:choose>
										width="148"/>
									</div>
									<%--判断是否为编辑模式--%>
									<c:if test="${state == 'edit'}">
										<div>
											<input id="tempImgName_${status.index}" type="hidden" />
											<input id="logoFile_${status.index}" name="logoFile_${status.index}" type="file" onchange="changeLogoPath(${status.index})" style="width:68px;" />
										</div>
									</c:if>
								</td>
							</c:if>
							
							<%--显示演员名--%>
							<c:if test="${showCol.showName}">
								<td align="center">
									<%--判断是否为编辑模式--%>
									<c:choose>  
										<c:when test="${state == 'edit'}">
											<div>
												<input id="name_${status.index}" type="text" value="${aActor.name}" style="width:100px;" />
											</div>
											<div>
												<A href="/movieList/a${aActor.id}" class="itemA" target="_blank" title="/movieList/a${aActor.id}">[查看]</A>
											</div>
										</c:when>
										<c:otherwise>
											<A href="/movieList/a${aActor.id}" class="itemA" target="_blank" title="/movieList/a${aActor.id}">
												<%--判断是否需要本列关键字变红--%>
												<c:choose>  
													<c:when test="${searchType==''}">
														${fn:replace(aActor.name,searchKey,redSearchKey)}
													</c:when>
													<c:otherwise>
														${aActor.name}
													</c:otherwise>
												</c:choose>
											</A>
										</c:otherwise>
									</c:choose>
								</td>
							</c:if>
							
							<%--显示百科信息--%>
							<c:if test="${showCol.showBaikeInfo}">
								<%--显示百科--%>
								<c:if test="${showCol.showBaike}">
									<td>
										<%--判断是否为编辑模式--%>
										<c:choose>  
											<c:when test="${state == 'edit'}">
												<div>
													<input id="baikeUrl_${status.index}" type="text" value="${aActor.baikeUrl}" style="width:95%;"/>
												</div>
												<div>
													<A href="http://baike.baidu.com/search?word=${aActor.name}" class="itemA" target="_blank" title="http://baike.baidu.com/search?word=${aActor.name}">[搜索]</A>
													<c:if test="${aActor.baikeUrl !=''}">
														<A href="${aActor.baikeUrl}" class="itemA" target="_blank" title="${aActor.baikeUrl}">[查看]</A>
													</c:if>
												</div>
											</c:when>
											<c:otherwise>
												<A href="${aActor.baikeUrl}" class="itemA" target="_blank" title="${aActor.baikeUrl}">${aActor.baikeUrl}</A>
											</c:otherwise>
										</c:choose>
									</td>
								</c:if>
								
								<%--显示新浪微博--%>
								<c:if test="${showCol.showXlwb}">
									<td>
										<%--判断是否为编辑模式--%>
										<c:choose>  
											<c:when test="${state == 'edit'}">
												<div>
													<input id="xlwbUrl_${status.index}" type="text" value="${aActor.xlwbUrl}" style="width:95%;"/>
												</div>
												<div>
													<A href="http://s.weibo.com/weibo/${aActor.name}" class="itemA" target="_blank" title="http://s.weibo.com/weibo/${aActor.name}">[搜索]</A>
													<c:if test="${aActor.xlwbUrl !=''}">
														<A href="${aActor.xlwbUrl}" class="itemA" target="_blank" title="${aActor.xlwbUrl}">[查看]</A>
													</c:if>
												</div>
											</c:when>
											<c:otherwise>
												<A href="${aActor.xlwbUrl}" class="itemA" target="_blank" title="${aActor.xlwbUrl}">${aActor.xlwbUrl}</A>
											</c:otherwise>
										</c:choose>
									</td>
								</c:if>
								
								<%--显示腾讯微博--%>
								<c:if test="${showCol.showTxwb}">
									<td>
										<%--判断是否为编辑模式--%>
										<c:choose>  
											<c:when test="${state == 'edit'}">
												<div>
													<input id="txwbUrl_${status.index}" type="text" value="${aActor.txwbUrl}" style="width:95%;"/>
												</div>
												<div>
													<A href="http://search.t.qq.com/user.php?k=${aActor.name}" class="itemA" target="_blank" title="search.t.qq.com/user.php?k=${aActor.name}">[搜索]</A>
													<c:if test="${aActor.txwbUrl !=''}">
														<A href="${aActor.txwbUrl}" class="itemA" target="_blank" title="${aActor.txwbUrl}">[查看]</A>
													</c:if>
												</div>
											</c:when>
											<c:otherwise>
												<A href="${aActor.txwbUrl}" class="itemA" target="_blank" title="${aActor.txwbUrl}">${aActor.txwbUrl}</A>
											</c:otherwise>
										</c:choose>
									</td>
								</c:if>
								
								<%--显示百度贴吧--%>
								<c:if test="${showCol.showBdtb}">
									<td>
										<%--判断是否为编辑模式--%>
										<c:choose>  
											<c:when test="${state == 'edit'}">
												<div>
													<input id="bdtbUrl_${status.index}" type="text" value="${aActor.bdtbUrl}" style="width:95%;"/>
												</div>
												<div>
													<A href="http://tieba.baidu.com/f?kw=${aActor.name}" class="itemA" target="_blank" title="http://tieba.baidu.com/f?kw=${aActor.name}">[搜索]</A>
													<c:if test="${aActor.bdtbUrl != ''}">
														<A href="${aActor.bdtbUrl}" class="itemA" target="_blank" title="${aActor.bdtbUrl}">[查看]</A>
													</c:if>
												</div>
											</c:when>
											<c:otherwise>
												<A href="${aActor.bdtbUrl}" class="itemA" target="_blank" title="${aActor.bdtbUrl}">${aActor.bdtbUrl}</A>
											</c:otherwise>
										</c:choose>
									</td>
								</c:if>
							</c:if>
							
							<%--显示电影信息--%>
							<c:if test="${showCol.showMovieInfo}">
								<%--显示电影--%>
								<c:if test="${showCol.showMovie}">
									<td>
										<div style="max-height:200px; border:1px solid black; overflow-y:auto;">
											<%--子集表格--%>
											<table border="1">
												<c:forEach items="${aActor.movieActorList}" varStatus="movieStatus" var="aMovieActor">
													<tr>
														<td>${movieStatus.index}</td>
														<td>
															${aMovieActor.id}
															<input id="movieActorId_${status.index}_${movieStatus.index}" type="hidden" value="${aMovieActor.id}"/>
														</td>
														<%--电影名称--%>
														<td>
															<%--判断是否为编辑模式--%>
															<c:choose>  
																<c:when test="${state == 'edit'}">
																	<input id="movieName_${status.index}_${movieStatus.index}" type="text" value="${aMovieActor.movieName}" style="width:100px;" />
																</c:when>
																<c:otherwise>
																	<%--判断是否存在重复的电影名--%>
																	<c:set var="movieIsRepeat" value="false"/>
																	<c:forEach items="${aActor.movieActorList}" var="otherMovieActor">
																		<c:if test="${aMovieActor.movieId==otherMovieActor.movieId && aMovieActor.id!=otherMovieActor.id}">
																			<c:set var="movieIsRepeat" value="true"/>
																		</c:if>
																	</c:forEach>
																	<font 
																		<c:choose>  
																			<c:when test="${movieIsRepeat == 'true'}">
																				class="repeatFont"
																			</c:when>
																			<c:otherwise>
																				class="itemFont"
																			</c:otherwise>
																		</c:choose>  
																	>
																		<%--判断是否需要本列关键字变红--%>
																		<c:choose>  
																			<c:when test="${searchType=='movie'}">
																				${fn:replace(aMovieActor.movieName,searchKey,redSearchKey)}
																			</c:when>
																			<c:otherwise>
																				${aMovieActor.movieName}
																			</c:otherwise>
																		</c:choose>
																	</font>
																</c:otherwise>
															</c:choose>
														</td>
														<td>
															<font class="itemFont">饰</font>
														</td>
														<%--电影中饰演角色名称--%>
														<td>
															<%--判断是否为编辑模式--%>
															<c:choose>  
																<c:when test="${state == 'edit'}">
																	<input id="roleName_${status.index}_${movieStatus.index}" type="text" value="${aMovieActor.roleName}" style="width:100px;" />
																</c:when>
																<c:otherwise>
																	<font class="itemFont">
																		<%--判断是否需要本列关键字变红--%>
																		<c:choose>  
																			<c:when test="${searchType=='role'}">
																				${fn:replace(aMovieActor.roleName,searchKey,redSearchKey)}
																			</c:when>
																			<c:otherwise>
																				${aMovieActor.roleName}
																			</c:otherwise>
																		</c:choose>
																	</font>
																</c:otherwise>
															</c:choose>
														</td>
														<%--电影权重--%>
														<td>
															<%--判断是否为编辑模式--%>
															<c:choose>  
																<c:when test="${state == 'edit'}">
																	<input id="roleWeight_${status.index}_${movieStatus.index}" type="text" value="${aMovieActor.weight}" style="width:30px;" />
																</c:when>
																<c:otherwise>
																	<font class="itemFont">${aMovieActor.weight}</font>
																</c:otherwise>
															</c:choose>
														</td>
														<td>
															<font class="itemFont" title="${aMovieActor.createTime}">${aMovieActor.createTimeString}</font>
														</td>
														<td>
															<font class="itemFont" title="${aMovieActor.updateTime}">${aMovieActor.updateTimeString}</font>
														</td>
														<td>
															<A href="javascript:clickDeleteMovieActor(${aMovieActor.id})" class="itemA">[删除]</A>
														</td>
													</tr>
												</c:forEach>
												<%--添加电影--%>
												<c:if test="${state == 'edit'}">
													<tr>
														<td></td>
														<td></td>
														<%--添加电影名称--%>
														<td>
															<input id="addMovieName_${status.index}" type="text" style="width:100px;" />
														</td>
														<td>
															<font class="itemFont">饰</font>
														</td>
														<%--添加电影角色名称--%>
														<td>
															<input id="addRoleName_${status.index}" type="text" style="width:100px;" />
														</td>
														<%--添加电影权重--%>
														<td>
															<input id="addRoleWeight_${status.index}" type="text" style="width:30px;" />
														</td>
														<td></td>
														<td></td>
														<td>
															<A href="javascript:clickAddMovieActor(${status.index})" class="itemA">[新增]</A>
														</td>
													</tr>
												</c:if>
											</table>
											<%--隐藏的电影数量用于计算JS循环其取值次数--%>
											<input id="movieCount_${status.index}" type="hidden" value="${aActor.movieCount}"/>
										</div>
									</td>
								</c:if>
								
								<%--显示电影数量--%>
								<c:if test="${showCol.showMovieCount}">
									<td align="center">
										${aActor.movieCount}
									</td>
								</c:if>
							</c:if>
							<%--显示权重--%>
							<c:choose>
								<c:when test="${showCol.showWeight}">
									<td align="center">
										<%--判断是否为编辑模式--%>
										<c:choose>  
											<c:when test="${state == 'edit'}">
												<input id="weight_${status.index}" type="text" value="${aActor.weight}" style="width:30px;"/>
											</c:when>
											<c:otherwise>
												<font class="itemFont">${aActor.weight}</font>
											</c:otherwise>
										</c:choose>
									</td>
								</c:when>
								<c:otherwise>
									<input id="weight_${status.index}" type="hidden" value="${aActor.weight}"/>
								</c:otherwise>
							</c:choose>
							
							<%--显示创建时间--%>
							<c:if test="${showCol.showCreateTime}">
								<td align="center">
									<font class="itemFont" title="${aActor.createTime}">${aActor.createTimeString}</font>
								</td>
							</c:if>
							
							<%--显示更新时间--%>
							<c:if test="${showCol.showUpdateTime}">
								<td align="center">
									<font class="itemFont" title="${aActor.updateTime}">${aActor.updateTimeString}</font>
								</td>
							</c:if>
							
							<td align="center">
								<div>
									<A href="javascript:clickDeleteActor(${aActor.id})" class="itemA">[删除]</A>
								</div>
								<div>
									<A href="javascript:clickMergeSelectActor(${aActor.id})" class="itemA">[合并选中]</A>
								</div>
							</td>
						</tr>
					</c:forEach>
				</table>
			</div>
			<div>
				<input id="pageNo" name="pageNo" type="hidden" value="${pageNo}" />
				共找到${infoCount}条信息 每页显示
				<select id="pageSize" onchange="changeShowState()">
					<%
						List<Long> pageSizeList = new Vector<Long>();
						pageSizeList.add(new Long(5));
						pageSizeList.add(new Long(10));
						pageSizeList.add(new Long(20));
						pageSizeList.add(new Long(50));
						pageSizeList.add(new Long(100));
						request.setAttribute("pageSizeList",pageSizeList); 
					%>
					<c:forEach items="${pageSizeList}" var="aPageSize">
						<option value="${aPageSize}" <c:if test="${pageSize==aPageSize}">selected="selected"</c:if>>${aPageSize}</option>
					</c:forEach>
				</select>
				条 当前在第${pageNo}/${pageCount}页
				<%--当前不是第一页--%>
				<c:if test="${pageNo != 1}">
					<A class="itemA" href="javascript:clickPageNo(1)">首页</A>
					<A class="itemA" href="javascript:clickPageNo(${pageNo - 1})">上一页</A>
				</c:if>
				<%--当前不是最后一页--%>
				<c:if test="${pageNo != pageCount}">
					<A class="itemA" href="javascript:clickPageNo(${pageNo + 1})">下一页</A>
					<A class="itemA" href="javascript:clickPageNo(${pageCount})">尾页</A>
				</c:if>
			</div>
		</div>
	</form>
</body>
<script type="text/javascript">
	<%--点击清除关键字--%>
	function clickClearSearchKey(){
		$("#searchKey").val("");
		$("#searchForm").submit();
	}
	
	<%--点击页号--%>
	function clickPageNo(no){
		$("#pageNo").val(no);
		$("#searchForm").submit();
	}
	
	<%--提交搜索表单--%>
	function submitSearchForm(){
		$("#searchForm").submit();
	}
	
	<%--提交搜索的Form表单--%>
	$("#searchForm").submit(function(){
		var searchType = $("#searchType").val();
		var searchKey = $("#searchKey").val();
		var state = $("#state").val();
		var showRow = $("#showRow").val();
		var pageNo = $("#pageNo").val();
		
		if(searchType == ""){
			$("#searchType").removeAttr("name"); 
		}
		
		if(searchKey == ""){
			$("#searchKey").removeAttr("name");
		}
		
		if(state == ""){
			$("#state").removeAttr("name");
		}
		
		if(showRow == ""){
			$("#showRow").removeAttr("name");
		}
		
		if(pageNo == "1"){
			$("#pageNo").removeAttr("name");
		}
		
		$("#showBaikeInfo").removeAttr("name");
		$("#showMovieInfo").removeAttr("name");
		$("#showCreateTime").removeAttr("name");
		$("#showUpdateTime").removeAttr("name");
		
		var pageSize = 	parseInt($("#pageSize").val());
		for(var i = 0; i < pageSize ; i++){
			$("#logoFile_" + i).removeAttr("name");
		}
	});
	
	<%--改变显示状态--%>
	function changeShowState(){
		var dataSet = {
			"pageSize":$("#pageSize").val(),
			"order":$("#order").val(),
			"asc":$("#asc").is(":checked"),
			
			"showLogo":$("#showLogo").is(":checked"),
			"showName":$("#showName").is(":checked"),
			
			"showBaikeInfo":$("#showBaikeInfo").is(":checked"),
			"showBaike":$("#showBaike").is(":checked"),
			"showXlwb":$("#showXlwb").is(":checked"),
			"showTxwb":$("#showTxwb").is(":checked"),
			"showBdtb":$("#showBdtb").is(":checked"),
			
			"showMovieInfo":$("#showMovieInfo").is(":checked"),
			"showMovie":$("#showMovie").is(":checked"),
			"showMovieCount":$("#showMovieCount").is(":checked"),
			
			"showWeight":$("#showWeight").is(":checked"),
			"showCreateTime":$("#showCreateTime").is(":checked"),
			"showUpdateTime":$("#showUpdateTime").is(":checked")
		};
		
		tool.ajax({
			requestUrl:"/admin/ajax?action=actorListUpdateShowCol",
			overtimeUrl:"/admin/login",
			dataSet:dataSet,
			success:function(msg){
				if(msg.stateCode == "success"){
					window.location.reload();
				}
			}
		});
	}
	
	<%--点击编辑--%>
	function clickEdit(){
		$("#state").val("edit");
		$("#searchForm").submit();
	}
	
	<%--点击保存--%>
	function clickSave(){
		var pageSize = 	parseInt($("#pageSize").val());
		var dataSet = {};
		for(var i = 0 ; i < pageSize ; i++){
			var id = $("#id_" + i).val();
			var name = $("#name_" + i).val();
			var tempImgName = $("#tempImgName_" + i).val();
			var baikeUrl = $("#baikeUrl_" + i).val();
			var xlwbUrl = $("#xlwbUrl_" + i).val();
			var txwbUrl = $("#txwbUrl_" + i).val();
			var bdtbUrl = $("#bdtbUrl_" + i).val();
			var weight = $("#weight_" + i).val();
			var movieCount = parseInt($("#movieCount_" + i).val());
			
			dataSet["id_"+i] = id;
			dataSet["name_"+i] = name;
			dataSet["tempImgName_"+i] = tempImgName;
			dataSet["baikeUrl_"+i] = baikeUrl;
			dataSet["xlwbUrl_"+i] = xlwbUrl;
			dataSet["txwbUrl_"+i] = txwbUrl;
			dataSet["bdtbUrl_"+i] = bdtbUrl;
			dataSet["weight_"+i] = weight;
			dataSet["movieCount_"+i] = movieCount;
			
			for(var j = 0 ; j < movieCount ; j++){
				var movieActorId = $("#movieActorId_"+i+"_"+j).val();
				var movieName = $("#movieName_"+i+"_"+j).val();
				var roleName = $("#roleName_"+i+"_"+j).val();
				var roleWeight = $("#roleWeight_"+i+"_"+j).val();
				
				dataSet["movieActorId_"+i+"_"+j] = movieActorId;
				dataSet["movieName_"+i+"_"+j] = movieName;
				dataSet["roleName_"+i+"_"+j] = roleName;
				dataSet["roleWeight_"+i+"_"+j] = roleWeight;
			}
		}
		
		tool.ajax({
			requestUrl:"/admin/ajax?action=actorListSave",
			overtimeUrl:"/admin/login",
			dataSet:dataSet,
			success:function(msg){
				<%--演员名已存在--%>
				if(msg.stateCode == "name_exist"){
					alert("演员名\""+msg.name+"\"已存在");
				}
				<%--电影名不存在--%>
				else if(msg.stateCode == "movieName_not_exist"){
					alert("电影名\""+msg.name+"\"不存在");
				}
				<%--成功--%>
				else if(msg.stateCode == "success"){
					<%--调用取消编辑刷新页面--%>
					clickCancelEdit();
				}
			}
		});
	}
	
	<%--点击取消编辑--%>
	function clickCancelEdit(){
		$("#state").val("");
		$("#searchForm").submit();
	}
	
	<%--改变Logo路径事件--%>
	function changeLogoPath(no){
		tool.fileUpload({
			requestUrl:"/admin/ajax?action=uploadImg",
			overtimeUrl:"/admin/login",
			fileId:"logoFile_"+no,
			success:function(msg){
				if(msg.stateCode == "success"){
					$("#logoImg_"+no).attr("src","/image/temp/"+msg.tempImgName);
					$("#tempImgName_"+no).val(msg.tempImgName);
				}
				else if(msg.stateCode == "not_upload"){
					alert("没有上传海报");
				}
				else if(msg.stateCode == "error"){
					alert("上传错误,可能是格式错误");
				}
			}
		});
	}
	
	<%--点击添加电影演员--%>
	function clickAddMovieActor(no){
		var movieName = $("#addMovieName_"+no).val();
		var actorId = $("#id_"+no).val();
		var roleName = $("#addRoleName_"+no).val();
		var weight = $("#addRoleWeight_"+no).val();

		var dataSet = {
			"movieName":movieName,
			"actorId":actorId,
			"roleName":roleName,
			"weight":weight
		};
		
		tool.ajax({
			requestUrl:"/admin/ajax?action=actorListAddMovieActor",
			overtimeUrl:"/admin/login",
			dataSet:dataSet,
			success:function(msg){
				<%--电影名不存在--%>
				if(msg.stateCode == "movieName_not_exist"){
					alert("输入的电影名不存在");
				}
				<%--成功--%>
				else if(msg.stateCode == "success"){
					$("#searchForm").submit();
				}
			}
		});
	}
	
	<%--点击全选--%>
	function clickSelectAll(){
		var selectAll = $("#selectAll").is(":checked");
		var pageSize = 	parseInt($("#pageSize").val());
		for(var i = 0 ; i < pageSize ; i++){
			$("#select_"+i).attr("checked",selectAll);
		}
	}
	
	<%--点击删除电影演员--%>
	function clickDeleteMovieActor(id){
		if(confirm("确定删除参演电影?")){
			var dataSet = {
				"id":id
			};
			
			tool.ajax({
				requestUrl:"/admin/ajax?action=actorListDeleteMovieActor",
				overtimeUrl:"/admin/login",
				dataSet:dataSet,
				success:function(msg){
					<%--成功--%>
					if(msg.stateCode == "success"){
						$("#searchForm").submit();
					}
				}
			});
		}
	}
	
	<%--点击删除选中演员--%>
	function clickDeleteSelectActor(){
		var pageSize = 	parseInt($("#pageSize").val());
		var dataSet = {};
		var dataCount = 0;
		for(var i = 0 ; i < pageSize ; i++){
			<%--获得选中行的 演员ID--%>
			var select = $("#select_"+i).is(":checked");
			if(select){
				dataSet["id_"+dataCount] = $("#id_" + i).val();
				dataCount++;
			}
		}
		if(dataCount!=0 && confirm("确定删除选中演员?")){
			dataSet["count"] = dataCount;
			tool.ajax({
				requestUrl:"/admin/ajax?action=actorListDeleteActor",
				overtimeUrl:"/admin/login",
				dataSet:dataSet,
				success:function(msg){
					<%--成功--%>
					if(msg.stateCode == "success"){
						$("#searchForm").submit();
					}
				}
			});
		}
	}
	
	<%--点击删除演员--%>
	function clickDeleteActor(id){
		if(confirm("确定删除演员?")){
			var dataSet = {
				"id_0":id,
				"count":1
			};
			tool.ajax({
				requestUrl:"/admin/ajax?action=actorListDeleteActor",
				overtimeUrl:"/admin/login",
				dataSet:dataSet,
				success:function(msg){
					<%--成功--%>
					if(msg.stateCode == "success"){
						$("#searchForm").submit();
					}
				}
			});
		}
	}
	
	<%--点击合并选中演员--%>
	function clickMergeSelectActor(id){
		var pageSize = 	parseInt($("#pageSize").val());
		var dataSet = {};
		var dataCount = 0;
		for(var i = 0 ; i < pageSize ; i++){
			<%--获得选中行的 演员ID--%>
			var select = $("#select_"+i).is(":checked");
			if(select){
				var selectId = $("#id_" + i).val();
				dataSet["id_"+dataCount] = selectId;
				dataCount++;
			}
		}
		if(dataCount > 1 && confirm("确定合并选中演员?")){
			dataSet["count"] = dataCount;
			dataSet["holdId"] = id;
			
			tool.ajax({
				requestUrl:"/admin/ajax?action=actorListMergeActor",
				overtimeUrl:"/admin/login",
				dataSet:dataSet,
				success:function(msg){
					<%--成功--%>
					if(msg.stateCode == "success"){
						$("#searchForm").submit();
					}
				}
			});
		}
	}
</script>
</html>
